/**
 * Created by WYH on 17/4/22.
 */
angular.module('lockList', []).component(
    'lockList',
    {
        templateUrl: 'component/lock/lockList/lock_list.template.html',
        controller: ['$scope', '$state', function ($scope, $state) {

            $scope.isSubmitLock=true;

            $scope.isCanEdit = $scope.$parent.isCanEdit;


            $scope.clickModify = function (lock) {
                $scope.$parent.modifyLock=lock;
                $scope.$parent.showLockFillIn=true;
            };

            $scope.clickLock = function (lock) {
                $scope.$parent.selectedLock = lock;
            };

            $scope.clickAuth = function (lock) {
                $state.go('company.managerLockAuth', {selectLock: lock});
            };

            $scope.getSelectedClass = function (lock) {
                return {
                    true: 'loger-selected'
                }[$scope.$parent.selectedLock==lock && $scope.isCanEdit]
            };

            $scope.getLockBoxStyle = function() {
                var lockContentHtml = document.getElementsByClassName('lock-content')[0];
                var width = lockContentHtml.clientWidth;
                var style = {};

                var height = width * 0.2874;
                style["height"] = height + 'px';
                style["line-height"] = height + 'px';

                return style;
            };

            $scope.getLockTextBoxStyle = function () {
                var lockIconBox = document.getElementById('lockIconBox');
                return {
                    "margin-left": lockIconBox.clientWidth + 'px'
                }
            };

            $scope.getLockTextContentStyle = function () {
                var lockTextContent = document.getElementById('lockTextContent');
                var lockContentHtml = document.getElementsByClassName('lock-content')[0];
                var style = {
                    "line-height": lockTextContent.clientHeight + 'px'
                };
                if (lockContentHtml.clientWidth <= 350) {
                    style["font-size"] = '1.2em';
                } else if (lockContentHtml.clientWidth <= 440) {
                    style["font-size"] = '1.3em';
                }
                return style;
            }


        }]
    }
);